package helper.base

import helper.base.CopyHelper.Expand.toClipboard
import helper.base.PrintHelper.StringTo.toPrintln
import java.util.*

//不考虑多线程
object ScannerHelper {
    private val scanner = Scanner(System.`in`)

    fun doMap1(
        init: (String) -> Unit,
    ) {
        while (scanner.hasNext()) {
            var lineStr = scanner.nextLine()
            lineStr = lineStr.trim()
            init(lineStr)
        }
    }

    fun doMap2(
        init: (String) -> String,
    ) {
        while (scanner.hasNext()) {
            var lineStr = scanner.nextLine()
            lineStr = lineStr.trim()
            lineStr = init(lineStr)
            lineStr.toPrintln()
            lineStr.toClipboard()
        }
    }

    fun doMap3(
        init: (String) -> String,
    ) {
        while (scanner.hasNext()) {
            scanner.nextLine()
            var lineStr = CopyHelper.getFromClipboard()
            lineStr = lineStr.trim()
            lineStr = init(lineStr)
            lineStr.toPrintln()
            lineStr.toClipboard()
        }
    }
}